﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BP
{
    class BpHelper
    {
        public List<string> VypsaniDisciplin(string nazevDiscipliny)
        {
            string[] split = nazevDiscipliny.Split(new Char[] { ';' });
            var dbConnection = new DbContext();
            var disciplinyList = new List<string>();
            for (int i = 0; i < split.Length - 1; i++)
            {
                IQueryable<disciplina> discipliny = dbConnection.disciplinas.Where(dis => dis.nazev == split[i]);

                foreach (var disci in discipliny)
                {
                    disciplinyList.Add(disci.zkratka /*+ " - " + disci.nazev + " - " + disci.pohlavi*/);
                    //vekDo = disci.vek_do.Value;
                    //vekOd = disci.vek_od.Value;
                    //pohlavi = disci.pohlavi;
                }
            }
            return disciplinyList;
        }

        public static List<string> VypsaniOrganizaci()
        {
            var dbConnection = new DbContext();

            var organizaces = from org in dbConnection.organizaces
                              select org;
            var organizaceList = new List<string>();

            foreach (var organizace in organizaces)
            {
                organizaceList.Add(organizace.jmeno);
            }
            return organizaceList;
        }

        public List<int> VypsaniZavodniku()
        {
            using (var db = new DbContext())
            {
                var zavodnicis = from zav in db.zavodnicis
                                 select zav;
                var zavodnikList = new List<int>();

                foreach (var zavodnik in zavodnicis)
                {
                    zavodnikList.Add(zavodnik.cislo_prukazu);         // nacteni cisla prukazu do comboboxu pri nacteni formulare
                }

                return zavodnikList;
            }
        }

        public static List<string> VypsaniSoutezi()
        {
            using (var db = new DbContext())
            {
                var sout = from sou in db.soutezs
                           select sou;
                var soutezList = new List<string>();

                foreach (var soutez in sout)
                {
                    soutezList.Add(soutez.misto);
                }

                return soutezList;
            }

        }
    }
}
